﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyDelegate2;    //  MyDelegate2

public partial class Delegate_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Heater heater = new Heater();
        Alarm alarm = new Alarm();

        heater.Boiled += alarm.MakeAlert;   //注册方法
        heater.Boiled += (new Alarm()).MakeAlert;      //给匿名对象注册方法
        heater.Boiled += new Heater.BoiledEventHandler(alarm.MakeAlert);    //也可以这么注册
        heater.Boiled += Display.ShowMsg;       //注册静态方法

        Label1.Text = heater.BoilWater();   //烧水，会自动调用注册过对象的方法
    }
}
